layui.config({
    base : "js/"
}).use(['form','layer','jquery','layedit','laydate'],function(){
    var form = layui.form(),
        layer = parent.layer === undefined ? layui.layer : parent.layer,
        $ = layui.jquery;

    form.on("submit(editBuilding)",function(data){
        var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
        $.ajax({
            type:'post',
            url:'/admin/building/update',
            async:false,
            data:{
                '_token':$('input[name=_token]').val(),
                'id':$('input[name=buildingName]').attr('key'),
                'area_id':$('#area_id').val(),
                'name':$('input[name=buildingName]').val(),
                'longitude':$('input[name=long]').val(),
                'latitude':$('input[name=lat]').val()
            },
            dataType:'json',
            success:function (data) {
                if(data.status == 1){
                    top.layer.close(index);
                    top.layer.msg("建筑编辑成功！");
                    layer.closeAll("iframe");
                    //刷新父页面
                    parent.location.reload();
                }else{
                    top.layer.close(index);
                    top.layer.msg("建筑编辑失败！");
                }
            }
        })
        return false;
    })
})